package com.dykj.fireFighting.server.base.government.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dykj.fireFighting.api.base.government.entity.GovernmentProject;
import com.dykj.fireFighting.api.base.government.entity.GovernmentProjectOpt;
import com.dykj.fireFighting.api.base.government.entity.GovernmentProjectView;
import com.dykj.fireFighting.api.base.government.service.IGovernmentProjectService;
import com.dykj.fireFighting.api.base.government.service.IGovernmentProjectViewService;
import com.dykj.fireFighting.server.base.government.mapper.GovernmentProjectMapper;
import com.dykj.fireFighting.server.base.government.mapper.GovernmentProjectViewMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.io.Serializable;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Slf4j
@Service("GovernmentProjectServiceImpl")
@DubboService
@Transactional(rollbackFor = Exception.class)
public class GovernmentProjectServiceImpl extends ServiceImpl<GovernmentProjectMapper, GovernmentProject>  implements IGovernmentProjectService {
    @Override
    public GovernmentProject getOneById(String id) {
        return getOneById(id);
    }

    @Override
    public void saveOrUp(GovernmentProject governmentProject) {
        saveOrUp(governmentProject);
    }
    @Override
    public Map<String,Object> getBigData(){
        Map<String,Object> reMapped = new HashMap<>();
        /*GovernmentProjectView governmentProjectView=getOneById("1514593815219154947");*/
        /*reMapped.put("z1",governmentProjectView);*/
        return reMapped;
    }

    @Override
    public List<GovernmentProject> getGovProOpt() {
        QueryWrapper q=new QueryWrapper();
        q.select("id,p_name");
        q.groupBy("p_name");
        return list(q);
    }

    @Override
    public int getCountByDate(String stDate,String endDate) {
        QueryWrapper queryWrapper=new QueryWrapper();
        queryWrapper.between("create_time",stDate,endDate);
        return (int)count(queryWrapper);
    }

    @Override
    public List<GovernmentProject> getZddwTj(String stDate, String endDate) {
        QueryWrapper queryWrapper=new QueryWrapper();
        queryWrapper.select("main_unit ,count(0) as gov_area");
        queryWrapper.between("create_time",stDate,endDate);
        queryWrapper.groupBy("main_unit");
        return list(queryWrapper);
    }

}
